/**
 * 
 */
package org.oy.sealogger.parser;

import java.io.BufferedReader;
import java.io.FileReader;
import java.util.Vector;

/**
 * @author juho
 *
 */
public class NMEALogReader  implements Runnable {

	private boolean running = false;
	private BufferedReader inputStream = null;
	private Vector<NMEA0183Sentence> sentences = new Vector<NMEA0183Sentence>();
	private RMCSentence currentRMC = null;
	
	public NMEALogReader() {
		
	}
	
	public NMEALogReader(RMCSentence sentence) {
		currentRMC = sentence;
	}
	
	public void start() {
		running = true;
		Thread t = new Thread(this);
		t.start();
	}
	
	public void openFile(String filename) {

	}
	
	public void run() {
		try {
			inputStream = new BufferedReader(new FileReader("nmeaout.txt"));
			String str;
			while ((str = inputStream.readLine()) != null) {
				if (str.startsWith("$GPRMC")) {
					System.out.println(str);
					if (currentRMC == null) {
						currentRMC = new RMCSentence(str);
					} else {
						currentRMC.addSentence(str);
					}
					//sentences.add(new RMCSentence(str));
					
				}
				Thread.sleep(25);
			}
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

}
